package beans;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import dao.DAOConcessionaria;

import modelos.Concessionaria;

@ManagedBean(name = "beanConcessionaria")
@RequestScoped
public class BeanConcessionaria 
{
	private String razaoSocial;
	private String cnpj;
	private List<Concessionaria> concessionarias;
	
	public List<String> getConcess()
	{
		DAOConcessionaria daConcessionaria = null;
		List<String> nomes = null;
		try
		{
			daConcessionaria = new DAOConcessionaria();
			
			nomes = new ArrayList<String>();
			
			concessionarias = daConcessionaria.buscaConcessionarias();
			
			for(int i=0; i<concessionarias.size(); i++)
			{
				String nome = concessionarias.get(i).getRazaoSocial();
				
				nomes.add(nome);
			}
		}
		catch(Exception err)
		{
			err.printStackTrace();
		}
		
		return nomes;
	}
	
	public String getRazaoSocial() {
		return razaoSocial;
	}
	public void setRazaoSocial(String razaoSocial) {
		this.razaoSocial = razaoSocial;
	}
	public String getCnpj() {
		return cnpj;
	}
	public void setCnpj(String cnpj) {
		this.cnpj = cnpj;
	}
	public List<Concessionaria> getConcessionarias() 
	{
		return concessionarias;
	}
	public void setConcessionarias(List<Concessionaria> concessionarias) {
		this.concessionarias = concessionarias;
	}
}
